import { Request, Response } from 'express';
import Mock from 'mockjs';

// 获取公告列表
const getNotices = (req: Request, res: Response) => {
  res.json({
    code: 0,
    data: Mock.mock({
      total: 100,
      'items|10': [
        {
          id: '@id',
          'number|+1': 1,
          title: '@name',
          unit: '@name',
          'isRelease|0-1': 1,
          'type|1-3': 1,
          'status|0-2': 0,
          startTime: '@datetime()',
          endTime: '@datetime()',
        },
      ],
    }),
  });
};

// 创建公告
const createNotice = (req: Request, res: Response) => {
  res.json({
    code: 0,
    data: {
      id: '@id',
    },
  });
};

export default {
  'GET /api_v1/notices': getNotices,
  'POST /api_v1/notice': createNotice,
};
